package com.smartwebx.ha.web.admin.module.screen;


import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.Context;
import com.alibaba.citrus.turbine.Navigator;
import com.smartwebx.ha.biz.assign.HaAreaManager;
import com.smartwebx.ha.biz.assign.HaGroupManager;
import com.smartwebx.ha.biz.assign.HaUserManager;
import com.smartwebx.ha.dal.assign.bean.HaArea;
import com.smartwebx.ha.dal.assign.bean.HaGroup;
import com.smartwebx.ha.web.admin.common.HaUserSys;

public class Home {
	@Autowired
	private HaUserManager haUserManager;
	@Autowired
	private HaAreaManager haAreaManager;
	@Autowired
	private HaGroupManager haGroupManager;
	@Autowired
	private HttpServletRequest request;
	
	public void execute(Navigator nav,Context context,HttpSession session) throws Exception{
		HaUserSys user=(HaUserSys) session.getAttribute("haUser");
		HaArea area=haAreaManager.findOne(user.getAreaId());
		HaGroup group=haGroupManager.findOne(area.getGroupId());
		String roleType=null;
		if(user.getRoleId()==1){
			roleType="管理员";
		}else if(user.getRoleId()==2){
			roleType="专业用户";
		}else{
			roleType="浏览用户";
		}
		context.put("roleType", roleType);
		context.put("area", area);
		context.put("user", user);
		context.put("group", group);
		
		Cookie[] cs = request.getCookies();
		System.out.println(cs);
	}

}
